package com.rjyb.student_management_platform.service.Impl;

import com.rjyb.student_management_platform.dao.AdminInOpDao;
import com.rjyb.student_management_platform.pojo.Class;
import com.rjyb.student_management_platform.pojo.*;
import com.rjyb.student_management_platform.service.AdminInOpService;
import com.rjyb.student_management_platform.unit.common.Page;
import com.rjyb.student_management_platform.unit.common.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;

@Service
public class AdminInOpServiceImpl implements AdminInOpService {
    @Autowired
    AdminInOpDao admin;


    //查询所有学生
    @Override
    public List<Student> seleallstudent(Page page) {
        return admin.seleallstudent(page);
    }

    //查询全部班级
    @Override
    public List<Class> seleallclass() {
        return admin.seleallclass();
    }

    //查询所有老师
    @Override
    public List<Teacher> seleallteacher() {
        return admin.seleallteacher();
    }

    //条件查询学生
    @Override
    public List<Student> selestudet(long cid, long tid, String name) {
        if (cid==-1&&tid!=-1&&name!=null){
            return admin.selestudet1(tid,name);
        }else if(tid==-1&&cid!=-1&&name!=null){
            return admin.selestudet2(cid,name);
        }else if(tid!=-1&&cid!=-1&&name!=null){
            return admin.selestudet3(cid,tid,name);
        }else if(tid==-1&&cid==-1&&name!=null) {
            return admin.selestudet4(name);
        }
        return null;
    }

    @Override
    public int selpagenum() {
        return admin.selpagenum();
    }

    //查询班级

    @Override
    public List<Class> selectClass() {
        return admin.selectClass();
    }

    @Override
    public List<Class> selectClassTT(Pager pager) {
        return admin.selectClassTT(pager);
    }
    //查询班级的分页查询


    @Override
    public int selectClassCT() {
        return admin.selectClassCT();
    }

    @Override
    public List<Booksubject> selectBooksubject() {
        return admin.selectBooksubject();
    }

    @Override
    public List<Booksubject> selectBooksubjectT(Pager pager) {
        return admin.selectBooksubjectT(pager);
    }
    //查询班级的分页


    @Override
    public int selectBooksubjectC() {
        return admin.selectBooksubjectC();
    }

    //添加学生名字学号手机号班级
    @Override
    public void AddStudentNameClass(Student student) {
        admin.AddStudentNameClass(student);
    }

    //添加学生班级
    @Override
    public void AddStudentClass(Student student, String cid) {
        admin.AddStudentClass(student,cid);
    }

    //添加老师名字工号和所教
    @Override
    public void AddTeacherBooksubject(Teacher teacher) {
        admin.AddTeacherBooksubject(teacher);
    }

    @Override
    public void AddTeacherClass(String cid,Teacher teacher) {
        admin.AddTeacherClass(cid,teacher);
    }

    @Override
    public void AddClass(Class c) {
        admin.AddClass(c);
    }

    //查询所有老师
    @Override
    public List<HashMap> selectAllTeacher(Pager pager) {
        return admin.selectAllTeacher(pager);
    }

    @Override
    public int selectAllTeacherC() {
        return admin.selectAllTeacherC();
    }

    //查询所有班级
    @Override
    public List<HashMap> selectAllClass(Pager pager) {
        return admin.selectAllClass(pager);
    }

    @Override
    public int selectAllClassC() {
        return admin.selectAllClassC();
    }

    //通过班级查老师
    @Override
    public List<HashMap> selectTOfName(String className, Pager pager) {
        //判断用户是否在下拉框选择了，如果没有返回全部老师
        if (className != null) {
            return admin.selectTOfName(className, pager);
        } else {
            return admin.selectAllTeacher(pager);
        }
    }

    @Override
    public int selectTOfNameC(String className) {
        return admin.selectTOfNameC(className);
    }

    //通过老师名字查老师
    @Override
    public List<HashMap> selectTOfTName(String teacherName, Pager pager) {
        //判断用户是否在输入框输入了数据，如果没有返回全部老师
        if (teacherName != null) {
            return admin.selectTOfTName(teacherName, pager);
        } else {
            return admin.selectAllTeacher(pager);
        }
    }

    @Override
    public int selectTOfTNameC(String teacherName) {
        return admin.selectTOfTNameC(teacherName);
    }

    @Override
    public String toLogin(Admininop admininop, Model model, HttpSession session) {
        Admininop admin1 = admin.toLogin(admininop);
        if (admin1 != null) {
            session.setAttribute("admin", admin1);
            return "admin/index";
        }
        model.addAttribute("no", "验证失败");
        return "admin/login";

    }

    //查询作业
    @Override
    public List<HashMap> selectHomeWorkA(Pager pager) {
        return admin.selectHomeWorkA(pager);
    }

    @Override
    public Integer selectHomeWorkC() {
        return admin.selectHomeWorkC();
    }
    //查询作业关联班级

    @Override
    public List<HashMap> selectWorkClassname(long jid) {
        return admin.selectWorkClassname(jid);
    }
    //查询作业完成情况

    @Override
    public List<HashMap> selectWorkComplete(long jid, long cid) {
        return admin.selectWorkComplete(jid, cid);
    }
    //查询未完成学生

    //查看老师
    @Override
    public List<Teacher> seleteacher() {
        return admin.seleteacher();
    }

    //查看老师带的班级有没有重复的
    @Override
    public Class_Teacher selectClass_Teacher(Class_Teacher class_teacher) {
        return admin.selectClass_Teacher(class_teacher);
    }

    //查看学生有没有注册过
    @Override
    public Student ifselectStudent(Student student) {
        return admin.ifselectStudent(student);
    }

    //查看老师有没有注册过
    @Override
    public Teacher ifselectTeacher(Teacher teacher) {
        return admin.ifselectTeacher(teacher);
    }
    //考勤
    @Override
    public List<HashMap> selectAllAttendancd(long cid,Pager pager,long tid) {
        return admin.selectAllAttendancd(cid,pager,tid);
    }
    //考勤分页
    @Override
    public int selectAllAttendancdC(long cid, Pager pager,long tid) {
        return admin.selectAllAttendancdC(cid,pager,tid);
    }
    //通过第几节课查考勤
    @Override
    public List<HashMap> selectClassSection(Integer classsection,long cid,String atDate,long tid) {
        return admin.selectClassSection(classsection,cid,atDate,tid);
    }
    //查老师和带的班

    @Override
    public List<HashMap> selectClassT(Pager pager) {
        return admin.selectClassT(pager);
    }
    //查老师和带的班分页

    @Override
    public Integer selectClassC() {
        return admin.selectClassC();
    }

    //通过班级查考勤
    @Override
    public List<HashMap> selectCOfName(long cid) {
        return admin.selectCOfName(cid);
    }

    //通过老师名字查考勤
    @Override
    public List<HashMap> selectCOfAtt(String teacherName) {
        return admin.selectCOfAtt(teacherName);
    }

    //作业筛选
    @Override
    public List<HashMap> selectAllWorkPlus(long cid) {
        return admin.selectAllWorkPlus(cid);
    }
//作业的模糊查询
    @Override
    public List<HashMap> selectWorkN(String hoName) {
        return admin.selectWorkN(hoName);
    }

    //查看课程有没有给注册过
    @Override
    public Booksubject ViewCourseRegistrations(Booksubject booksubject) {
        return admin.ViewCourseRegistrations(booksubject);
    }

    //添加课程
    @Override
    public void AddCourse(Booksubject booksubject) {
        admin.AddCourse(booksubject);
    }

    //查看添加班级重复
    @Override
    public Class ClassQuery(Class c) {
        return admin.ClassQuery(c);
    }
}
